import React from 'react'
// import qs from 'querystring'

export default function Detail(props) {
  // console.log('Detail', props)
  // 接收params参数
  // const { id, title } = props.match.params

  // 接收search参数
  // const { search } = props.location
  // const { id, title } = qs.parse(search.slice(1))

  // 接收state参数
  const { state } = props.history.location
  const {id, title} = state || {}

  const DetailData = [
    { id: '01', content: 'Hello，World' },
    { id: '02', content: 'Hello，China' },
    { id: '03', content: 'Hello，MySelef in future' }
  ]

  const findResult = DetailData.find((detailObj) => {
    return detailObj.id === id
  }) || {}

  return (
    <ul>
      <li>ID:{id}</li>
      <li>TITLE:{title}</li>
      <li>CONTENT:{findResult.content}</li>
    </ul>
  )
}
